/**
 * Licensed under the MIT License
 *
 * Copyright (c) 2012 Gary Paluk, http://www.plugin.io
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

package io.plugin.blib.gfx 
{
	/**
	 * ...
	 * @author Gary Paluk - http://www.plugin.io
	 */
	public class BlibColor 
	{
		
		private var _r: Number;
		private var _g: Number;
		private var _b: Number;
		private var _a: Number;
		
		public static function get WHITE(): BlibColor
		{
			return new BlibColor( 1, 1, 1 );
		}
		
		public static function get BLACK(): BlibColor
		{
			return new BlibColor( 0, 0, 0 );
		}
		
		public function get r():Number 
		{
			return _r;
		}
		
		public function set r(value:Number):void 
		{
			_r = value;
		}
		
		public function get g():Number 
		{
			return _g;
		}
		
		public function set g(value:Number):void 
		{
			_g = value;
		}
		
		public function get b():Number 
		{
			return _b;
		}
		
		public function set b(value:Number):void 
		{
			_b = value;
		}
		
		public function get a():Number 
		{
			return _a;
		}
		
		public function set a(value:Number):void 
		{
			_a = value;
		}
		
		public function BlibColor( r: Number = 0, g: Number = 0, b: Number = 0, a: Number = 1 ) 
		{
			_r = r;
			_g = g;
			_b = b;
			_a = a;
		}
		
		public function toUint(): uint
		{
			
			var red: uint = uint( r * 255 ) << 24;
			var gree: uint = uint( g * 255 ) << 16;
			var blue: uint = uint( b * 255 ) << 8;
			var alpha: uint = uint( a * 255 );
			
			return ( red | green | blue | alpha );
		}
		
		public function toString(): String
		{
			return "[object BlibColor] (r: " + r + ", g: " + g + ", b: " + b + ", a: " + a + ")";
		}
		
	}

}